package edu.ucdavis.gwt.gis.client.toolbar;

import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class GeocodeResultsPanel extends PopupPanel {

	private SimplePanel panel = new SimplePanel();
	private VerticalPanel results = new VerticalPanel();
	
	private Widget searchPanel = null;
	
	public GeocodeResultsPanel(Widget searchPanel) {
		this.searchPanel = searchPanel;
		results.setWidth("100%");
		panel.add(results);
		setWidget(panel);
		setAnimationEnabled(true);
		setStyleName("innerMapPopup");
	}
	
	@Override 
	public void add(Widget w) {
		results.add(w);
	}
	
	@Override
	public void clear() {
		results.clear();
	}
	
	public int getResultCount() {
		return results.getWidgetCount();
	}
	
	public void addResult(Widget result) {
		results.add(result);
	}
	
	@Override
	public void show() {
		setWidth(searchPanel.getOffsetWidth()+"px");
		setPopupPosition(
				searchPanel.getAbsoluteLeft() - 15, 
				searchPanel.getAbsoluteTop()+searchPanel.getOffsetHeight()+10
		);
		super.show();
	}
	
}
